<!--
* @Author: white_queen
* @Date: 2024-07-21 13:49:45
* @LastEditors: white_queen
* @LastEditTime: 2024-07-21 13:50:07
* @FilePath: /pages/my/history/history.vue
* @Description: 浏览足迹页面
-->
<template>
	<view class="page">
		<product-list :list="list" @scrolltolower="scrolltolower"></product-list>
	</view>
</template>

<script>
import httpApi from '../../../http';
import productList from '@/components/productList/productList.vue';
import { calculateTotalPages } from '@/utils/index.js';
export default {
	components: {
		productList
	},
	data() {
		return {
			list: [],
			page: 1,
			total: 0
		};
	},
	onLoad() {
		this.init();
	},
	methods: {
		init() {
			httpApi.MyApi.getcollectList({ page: this.page, limit: 10 }).then((res) => {
				console.log(res.data.list);
				this.total = res.data.total;
				this.list = this.list.concat(res.data.list);
			});
		},
		// 触底
		scrolltolower() {
			this.page += 1;
			if (calculateTotalPages(this.total, 10) <= this.page) {
				uni.showToast({
					title: '没有更多了..',
					icon: 'none'
				});
			} else {
				this.init();
			}
		}
	}
};
</script>

<style lang="scss"></style>
